/*
 * Created by JFormDesigner on Fri Jun 18 11:52:35 GMT+08:00 2021
 */

package com.bk.view;

import javax.swing.plaf.*;
import com.bk.dao.BookDao;
import com.bk.dao.BookTypeDao;
import com.bk.dao.UserDao;
import com.bk.model.Book;
import com.bk.model.BookType;
import com.bk.model.User;
import com.bk.util.ToolUtil;
import sun.applet.Main;

import java.awt.*;
import java.awt.event.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.*;
import javax.swing.GroupLayout;
import javax.swing.event.*;
import javax.swing.table.*;

/**
 * @author Ayi
 */
public class MainFrame extends JFrame{
    private DefaultTableCellRenderer dr;

    public MainFrame() {
        initComponents();
        dr = new DefaultTableCellRenderer();
        UpdateTable.doClick();
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    // 点击菜单对应表隐藏与显示
    private void menuUserMouseClicked(MouseEvent e) {
        // TODO add your code here
        scrollPane0.setVisible(true);
        scrollPane1.setVisible(false);
        scrollPane2.setVisible(false);
        scrollPane3.setVisible(false);
        UpdateTable.doClick();
    }
    // 点击菜单对应表隐藏与显示
    private void menuBookMouseClicked(MouseEvent e) {
        // TODO add your code here
        scrollPane0.setVisible(false);
        scrollPane1.setVisible(true);
        scrollPane2.setVisible(false);
        scrollPane3.setVisible(false);
        UpdateTable.doClick();
    }
    // 点击菜单对应表隐藏与显示
    private void menuBookTypeMouseClicked(MouseEvent e) {
        // TODO add your code here
        scrollPane0.setVisible(false);
        scrollPane1.setVisible(false);
        scrollPane2.setVisible(true);
        scrollPane3.setVisible(false);
        UpdateTable.doClick();
    }
    // 点击菜单对应表隐藏与显示
    private void DesignerMouseClicked(MouseEvent e) {
        // TODO add your code here
        scrollPane0.setVisible(false);
        scrollPane1.setVisible(false);
        scrollPane2.setVisible(false);
        scrollPane3.setVisible(true);
        UpdateTable.doClick();
    }

    // 重置用户表
    public void setUsers() throws SQLException, ClassNotFoundException {
        // 重定义模型
        Vector<Vector<String>> vtUser = new Vector<Vector<String>>();
        Vector<String> headUser = new Vector<String>();
        headUser.add("用户id");
        headUser.add("用户名");
        headUser.add("借阅量");
        headUser.add("信用");
        DefaultTableModel userTableModel = new DefaultTableModel(vtUser, headUser);
        tableUser.setModel(userTableModel);
        // 从数据库取表
        ResultSet ut = new UserDao().getUserTable();
        // 初始化UI表内数据
        while (ut.next()) {
            Vector<String> temp = new Vector<String>();
            temp.add(ut.getString("uid"));
            temp.add(ut.getString("uname"));
            temp.add(ut.getString("ubooknums"));
            temp.add(ut.getString("ucredit"));
            vtUser.add(temp);
        }
        dr.setHorizontalAlignment(JLabel.CENTER);
        tableUser.setDefaultRenderer(Object.class, dr);
        scrollPane0.updateUI();
    }

    //重置图书表
    public void setBooks() throws SQLException, ClassNotFoundException {
        // 重定义模型
        Vector<Vector<String>> vtBook = new Vector<Vector<String>>();
        Vector<String> headBook = new Vector<String>();
        headBook.add("图书id");
        headBook.add("书名");
        headBook.add("类型");
        headBook.add("余量");
        DefaultTableModel bookTableModel = new DefaultTableModel(vtBook, headBook);
        tableBook.setModel(bookTableModel);
        // 从数据库取表
        ResultSet bt = new BookDao().getBookTable();
        // 初始化UI表内数据
        while (bt.next()) {
            Vector<String> temp = new Vector<String>();
            temp.add(bt.getString("bid"));
            temp.add(bt.getString("bname"));
            temp.add(bt.getString("btype"));
            temp.add(bt.getString("binventory"));
            vtBook.add(temp);
        }
        dr.setHorizontalAlignment(JLabel.CENTER);
        tableBook.setDefaultRenderer(Object.class, dr);
        scrollPane1.updateUI();
    }

    // 重置图书类型表
    public void setBookType() throws SQLException, ClassNotFoundException {
        // 重定义模型
        Vector<Vector<String>> vtBookType = new Vector<Vector<String>>();
        Vector<String> headBookType = new Vector<String>();
        headBookType.add("类型id");
        headBookType.add("类型名");
        headBookType.add("该类图书余量");
        DefaultTableModel bookTypeTableModel = new DefaultTableModel(vtBookType, headBookType);
        tableBookType.setModel(bookTypeTableModel);
        // 从数据库取表
        ResultSet btt = new BookTypeDao().getBookTypeTable();
        // 初始化UI表内数据
        while (btt.next()) {
            Vector<String> temp = new Vector<String>();
            temp.add(btt.getString("btid"));
            temp.add(btt.getString("btname"));
            temp.add(btt.getString("btinventory"));
            vtBookType.add(temp);
        }
        dr.setHorizontalAlignment(JLabel.CENTER);
        tableBookType.setDefaultRenderer(Object.class, dr);
        scrollPane2.updateUI();
    }

    // 刷新
    private void UpdateTableActionPerformed(ActionEvent e) {
        // TODO add your code here
        try {
            setUsers();
            setBooks();
            setBookType();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException classNotFoundException) {
            classNotFoundException.printStackTrace();
        }
    }

    // 用户，查找与编辑（监听）
    private void menuItem11ActionPerformed(ActionEvent e) {
        // TODO add your code here
        // 查找
        String idOrNameInfo = JOptionPane.showInputDialog(null, "请输入你要找的 id 或用户名吧~", "查找与编辑", 1);
        User user = null;
        if (idOrNameInfo != null) {
            boolean bool = new ToolUtil().judgeIdOrName(idOrNameInfo);
            if (bool) {
                try {
                    user = new UserDao().searchUserById(idOrNameInfo);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }else{
                try {
                    user = new UserDao().searchUserByName(idOrNameInfo);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (user == null) {
                JOptionPane.showMessageDialog(null, "系统君尽力了，找不到这个用户~");
                return;
            }
        }else {
            return;
        }
        String message = "昵称：" + user.getUname() + "\nuid：" + user.getUid() + "    信用：" + user.getUcredit() + "\n借阅量：" + user.getUbooknums();
        int ra = new ToolUtil().randomNumber();
        ImageIcon icon = ra == 0 ? new ImageIcon("src/images/wow00.png") : new ImageIcon("src/images/wow11.png");
        JOptionPane.showMessageDialog(null, message,"找到啦", 1, icon);

        // 编辑
        int editInfo = JOptionPane.showConfirmDialog(null, "要继续编辑么");
        if (editInfo == JOptionPane.YES_OPTION) {
            new uEditFrame(user).setVisible(true);
        }
    }

    // 用户，黑名单（监听）
    private void menuItem12ActionPerformed(ActionEvent e) {
        // TODO add your code here
        new blackList().setVisible(true);
    }

    // 图书类型，新增（监听）
    private void menuItem31ActionPerformed(ActionEvent e) {
        // TODO add your code here
        new addBookTypeFrame().setVisible(true);
    }

    // 图书类型，移除（监听）
    private void menuItem32ActionPerformed(ActionEvent e) {
        // TODO add your code here
        // 查找
        String idOrNameInfo = JOptionPane.showInputDialog(null, "请输入你要删除的类型id或类型名吧~", "移除图书类型", 1);
        BookType booktype = null;
        if (idOrNameInfo != null) {
            boolean bool = new ToolUtil().judgeIdOrName(idOrNameInfo);
            if (bool) {
                try {
                    booktype = new BookTypeDao().searchBookTypeById(idOrNameInfo);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }else{
                try {
                    booktype = new BookTypeDao().searchBookTypeByName(idOrNameInfo);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (booktype == null) {
                JOptionPane.showMessageDialog(null, "找不到这个类型");
                return;
            }
        }else {
            return;
        }
        String message = "类型名：" + booktype.getBtname() + "\nbtid：" + booktype.getBtid() + "     库存量：" + booktype.getBtinventory();
        ImageIcon icon = new ImageIcon("src/images/wow22.png");
        JOptionPane.showMessageDialog(null, message,"找到啦", 1, icon);

        // 删除
        int editInfo = JOptionPane.showConfirmDialog(null, "确定删除图书类型：" + booktype.getBtname() + " 么？\n（此类型下的书籍会一并下架）");
        if (editInfo == JOptionPane.YES_OPTION) {
            try {
                if (new BookTypeDao().deleteBookType(booktype)) {
                    JOptionPane.showMessageDialog(null, "删除成功");
                }else{
                    JOptionPane.showMessageDialog(null, "删除失败");
                }
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }

    // 图书类型，编辑（监听）
    private void menuItem33ActionPerformed(ActionEvent e) {
        // TODO add your code here
        // 查找
        String idOrNameInfo = JOptionPane.showInputDialog(null, "告诉我你要编辑的类型id或类型名吧~", "编辑图书类型", 1);
        BookType booktype = null;
        if (idOrNameInfo != null) {
            boolean bool = new ToolUtil().judgeIdOrName(idOrNameInfo);
            if (bool) {
                try {
                    booktype = new BookTypeDao().searchBookTypeById(idOrNameInfo);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }else{
                try {
                    booktype = new BookTypeDao().searchBookTypeByName(idOrNameInfo);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (booktype == null) {
                JOptionPane.showMessageDialog(null, "找不到这个类型");
                return;
            }
        }else {
            return;
        }
        String message = "类型名：" + booktype.getBtname() + "\nbtid：" + booktype.getBtid() + "     库存量：" + booktype.getBtinventory();
        ImageIcon icon = new ImageIcon("src/images/wow22.png");
        JOptionPane.showMessageDialog(null, message,"找到啦", 1, icon);

        // 编辑
        int editInfo = JOptionPane.showConfirmDialog(null, "要继续编辑么");
        if (editInfo == JOptionPane.YES_OPTION) {
            new btEditFrame(booktype).setVisible(true);
        }
    }

    // 图书，新增（监听）
    private void menuItem21ActionPerformed(ActionEvent e) {
        // TODO add your code here
        new addBookFrame().setVisible(true);
    }

    // 图书，下架（监听）
    private void menuItem22ActionPerformed(ActionEvent e) {
        // TODO add your code here
        // 查找
        String idOrNameInfo = JOptionPane.showInputDialog(null, "请输入你要下架的图书id或书名吧~", "下架图书", 1);
        Book book = null;
        if (idOrNameInfo != null) {
            boolean bool = new ToolUtil().judgeIdOrName(idOrNameInfo);
            if (bool) {
                try {
                    book = new BookDao().searchBookById(idOrNameInfo);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }else{
                try {
                    book = new BookDao().searchBookByName(idOrNameInfo);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (book == null) {
                JOptionPane.showMessageDialog(null, "找不到这本书");
                return;
            }
        }else {
            return;
        }
        String message =  "书名：" + book.getBname() + "\nbid：" + book.getBid() + "     余量：" + book.getBinventory();
        ImageIcon icon = new ImageIcon("src/images/book.png");
        JOptionPane.showMessageDialog(null, message,"找到啦", 1, icon);

        // 下架
        int editInfo = JOptionPane.showConfirmDialog(null, "确定下架《" + book.getBname() + "》么？");
        if (editInfo == JOptionPane.YES_OPTION) {
            try {
                if (new BookDao().deleteBook(book.getBname(), book.getBinventory(), book.getBtype())) {
                    JOptionPane.showMessageDialog(null, "下架成功");
                }else{
                    JOptionPane.showMessageDialog(null, "下架失败");
                }
            } catch (SQLException throwables) {
                throwables.printStackTrace();
            }
        }
    }

    // 图书，编辑（监听）
    private void menuItem23ActionPerformed(ActionEvent e) {
        // TODO add your code here
        // 查找
        String idOrNameInfo = JOptionPane.showInputDialog(null, "请输入你要找的图书id或书名吧~", "查找与编辑", 1);
        Book book = null;
        if (idOrNameInfo != null) {
            boolean bool = new ToolUtil().judgeIdOrName(idOrNameInfo);
            if (bool) {
                try {
                    book = new BookDao().searchBookById(idOrNameInfo);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }else{
                try {
                    book = new BookDao().searchBookByName(idOrNameInfo);
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (book == null) {
                JOptionPane.showMessageDialog(null, "找不到这本书");
                return;
            }
        }else {
            return;
        }
        String message =  "书名：" + book.getBname() + "\nbid：" + book.getBid() + "     余量：" + book.getBinventory();
        ImageIcon icon = new ImageIcon("src/images/book.png");
        JOptionPane.showMessageDialog(null, message,"找到啦", 1, icon);

        // 编辑
        int editInfo = JOptionPane.showConfirmDialog(null, "要继续编辑么？");
        if (editInfo == JOptionPane.YES_OPTION) {
            new bEditFrame(book).setVisible(true);
        }
    }

    // 其他，新建窗口（监听）
    private void menuItem1ActionPerformed(ActionEvent e) {
        // TODO add your code here
        new LoginFrame();
    }

    // 其他，退出登录（监听）
    private void menuItem0ActionPerformed(ActionEvent e) {
        // TODO add your code here
        new LoginFrame();
        dispose();
    }

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner Evaluation license - unknown
        menuBar1 = new JMenuBar();
        Designer = new JMenu();
        menuItem1 = new JMenuItem();
        menuItem0 = new JMenuItem();
        menuUser = new JMenu();
        menuItem11 = new JMenuItem();
        menuItem12 = new JMenuItem();
        menuBook = new JMenu();
        menuItem23 = new JMenuItem();
        menuItem21 = new JMenuItem();
        menuItem22 = new JMenuItem();
        menuBookType = new JMenu();
        menuItem31 = new JMenuItem();
        menuItem32 = new JMenuItem();
        menuItem33 = new JMenuItem();
        layeredPane1 = new JLayeredPane();
        UpdateTable = new JButton();
        panel1 = new JPanel();
        scrollPane2 = new JScrollPane();
        tableBookType = new JTable();
        scrollPane0 = new JScrollPane();
        tableUser = new JTable();
        scrollPane1 = new JScrollPane();
        tableBook = new JTable();
        scrollPane3 = new JScrollPane();
        label1 = new JLabel();

        //======== this ========
        setTitle("\u54c8\u54c8");
        setIconImage(new ImageIcon(getClass().getResource("/images/main.png")).getImage());
        setResizable(false);
        Container contentPane = getContentPane();

        //======== menuBar1 ========
        {

            //======== Designer ========
            {
                Designer.setText("\u5176\u4ed6");
                Designer.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 15));
                Designer.setBackground(Color.white);
                Designer.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        DesignerMouseClicked(e);
                    }
                });

                //---- menuItem1 ----
                menuItem1.setText("\u65b0\u5efa\u7a97\u53e3");
                menuItem1.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 12));
                menuItem1.addActionListener(e -> menuItem1ActionPerformed(e));
                Designer.add(menuItem1);

                //---- menuItem0 ----
                menuItem0.setText("\u9000\u51fa\u767b\u5f55");
                menuItem0.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 12));
                menuItem0.addActionListener(e -> menuItem0ActionPerformed(e));
                Designer.add(menuItem0);
            }
            menuBar1.add(Designer);

            //======== menuUser ========
            {
                menuUser.setText("\u7528\u6237\u7ba1\u7406");
                menuUser.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 15));
                menuUser.setBackground(Color.white);
                menuUser.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        menuUserMouseClicked(e);
                    }
                });

                //---- menuItem11 ----
                menuItem11.setText("\u67e5\u627e\u4e0e\u7f16\u8f91");
                menuItem11.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 12));
                menuItem11.addActionListener(e -> menuItem11ActionPerformed(e));
                menuUser.add(menuItem11);

                //---- menuItem12 ----
                menuItem12.setText("\u9ed1\u540d\u5355");
                menuItem12.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 12));
                menuItem12.addActionListener(e -> menuItem12ActionPerformed(e));
                menuUser.add(menuItem12);
            }
            menuBar1.add(menuUser);

            //======== menuBook ========
            {
                menuBook.setText("\u56fe\u4e66\u7ba1\u7406");
                menuBook.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 15));
                menuBook.setBackground(Color.white);
                menuBook.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        menuBookMouseClicked(e);
                    }
                });

                //---- menuItem23 ----
                menuItem23.setText("\u67e5\u627e\u4e0e\u7f16\u8f91");
                menuItem23.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 12));
                menuItem23.addActionListener(e -> menuItem23ActionPerformed(e));
                menuBook.add(menuItem23);

                //---- menuItem21 ----
                menuItem21.setText("\u4e0a\u67b6\u56fe\u4e66");
                menuItem21.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 12));
                menuItem21.addActionListener(e -> menuItem21ActionPerformed(e));
                menuBook.add(menuItem21);

                //---- menuItem22 ----
                menuItem22.setText("\u4e0b\u67b6\u56fe\u4e66");
                menuItem22.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 12));
                menuItem22.addActionListener(e -> menuItem22ActionPerformed(e));
                menuBook.add(menuItem22);
            }
            menuBar1.add(menuBook);

            //======== menuBookType ========
            {
                menuBookType.setText("\u56fe\u4e66\u7c7b\u578b\u7ba1\u7406");
                menuBookType.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 15));
                menuBookType.setBackground(Color.white);
                menuBookType.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        menuBookTypeMouseClicked(e);
                    }
                });

                //---- menuItem31 ----
                menuItem31.setText("\u65b0\u589e\u56fe\u4e66\u7c7b\u578b");
                menuItem31.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 12));
                menuItem31.addActionListener(e -> menuItem31ActionPerformed(e));
                menuBookType.add(menuItem31);

                //---- menuItem32 ----
                menuItem32.setText("\u79fb\u9664\u56fe\u4e66\u7c7b\u578b");
                menuItem32.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 12));
                menuItem32.addActionListener(e -> menuItem32ActionPerformed(e));
                menuBookType.add(menuItem32);

                //---- menuItem33 ----
                menuItem33.setText("\u56fe\u4e66\u7c7b\u578b\u7f16\u8f91");
                menuItem33.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 12));
                menuItem33.addActionListener(e -> menuItem33ActionPerformed(e));
                menuBookType.add(menuItem33);
            }
            menuBar1.add(menuBookType);

            //======== layeredPane1 ========
            {
                layeredPane1.setBackground(Color.white);
                layeredPane1.setForeground(Color.white);

                //---- UpdateTable ----
                UpdateTable.setText("\u5237\u65b0\u4e00\u4e0b");
                UpdateTable.setIcon(new ImageIcon(getClass().getResource("/images/find.png")));
                UpdateTable.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 15));
                UpdateTable.setBackground(Color.white);
                UpdateTable.addActionListener(e -> UpdateTableActionPerformed(e));
                layeredPane1.add(UpdateTable, JLayeredPane.DEFAULT_LAYER);
                UpdateTable.setBounds(-20, -15, 450, 55);
            }
            menuBar1.add(layeredPane1);
        }
        setJMenuBar(menuBar1);

        //======== panel1 ========
        {
            panel1.setBackground(Color.white);
            panel1.setMinimumSize(new Dimension(702, 384));
            panel1.setPreferredSize(new Dimension(703, 384));
            panel1.setBorder (new javax. swing. border. CompoundBorder( new javax .swing .border .TitledBorder (new javax. swing. border. EmptyBorder(
            0, 0, 0, 0) , "JFor\u006dDesi\u0067ner \u0045valu\u0061tion", javax. swing. border. TitledBorder. CENTER, javax. swing. border. TitledBorder
            . BOTTOM, new java .awt .Font ("Dia\u006cog" ,java .awt .Font .BOLD ,12 ), java. awt. Color.
            red) ,panel1. getBorder( )) ); panel1. addPropertyChangeListener (new java. beans. PropertyChangeListener( ){ @Override public void propertyChange (java .
            beans .PropertyChangeEvent e) {if ("bord\u0065r" .equals (e .getPropertyName () )) throw new RuntimeException( ); }} );

            //======== scrollPane2 ========
            {

                //---- tableBookType ----
                tableBookType.setEnabled(false);
                tableBookType.setFont(tableBookType.getFont().deriveFont(tableBookType.getFont().getSize() + 2f));
                scrollPane2.setViewportView(tableBookType);
            }

            //======== scrollPane0 ========
            {

                //---- tableUser ----
                tableUser.setPreferredSize(new Dimension(150, 40));
                tableUser.setModel(new DefaultTableModel(
                    new Object[][] {
                        {"", "", null, ""},
                    },
                    new String[] {
                        "\u7528\u6237id", "\u7528\u6237\u540d", "\u501f\u9605\u91cf", "\u4fe1\u7528"
                    }
                ) {
                    Class<?>[] columnTypes = new Class<?>[] {
                        Object.class, String.class, Integer.class, String.class
                    };
                    @Override
                    public Class<?> getColumnClass(int columnIndex) {
                        return columnTypes[columnIndex];
                    }
                });
                tableUser.setFillsViewportHeight(true);
                tableUser.setEnabled(false);
                tableUser.setFont(new Font("\u5fae\u8f6f\u96c5\u9ed1", Font.PLAIN, 14));
                scrollPane0.setViewportView(tableUser);
            }

            //======== scrollPane1 ========
            {
                scrollPane1.setEnabled(false);

                //---- tableBook ----
                tableBook.setEnabled(false);
                tableBook.setFont(tableBook.getFont().deriveFont(tableBook.getFont().getSize() + 2f));
                scrollPane1.setViewportView(tableBook);
            }

            //======== scrollPane3 ========
            {

                //---- label1 ----
                label1.setIcon(new ImageIcon(getClass().getResource("/images/cc.png")));
                scrollPane3.setViewportView(label1);
            }

            GroupLayout panel1Layout = new GroupLayout(panel1);
            panel1.setLayout(panel1Layout);
            panel1Layout.setHorizontalGroup(
                panel1Layout.createParallelGroup()
                    .addGroup(panel1Layout.createParallelGroup()
                        .addGroup(panel1Layout.createSequentialGroup()
                            .addGap(0, 0, Short.MAX_VALUE)
                            .addComponent(scrollPane3, GroupLayout.PREFERRED_SIZE, 702, GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE)))
                    .addGroup(panel1Layout.createParallelGroup()
                        .addGroup(panel1Layout.createSequentialGroup()
                            .addGap(0, 0, Short.MAX_VALUE)
                            .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 702, GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE)))
                    .addGroup(panel1Layout.createParallelGroup()
                        .addGroup(panel1Layout.createSequentialGroup()
                            .addGap(0, 0, Short.MAX_VALUE)
                            .addComponent(scrollPane0, GroupLayout.PREFERRED_SIZE, 702, GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE)))
                    .addComponent(scrollPane2, GroupLayout.PREFERRED_SIZE, 702, GroupLayout.PREFERRED_SIZE)
            );
            panel1Layout.setVerticalGroup(
                panel1Layout.createParallelGroup()
                    .addGroup(panel1Layout.createParallelGroup()
                        .addGroup(panel1Layout.createSequentialGroup()
                            .addGap(0, 0, Short.MAX_VALUE)
                            .addComponent(scrollPane3, GroupLayout.PREFERRED_SIZE, 378, GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE)))
                    .addGroup(panel1Layout.createParallelGroup()
                        .addGroup(panel1Layout.createSequentialGroup()
                            .addGap(0, 0, Short.MAX_VALUE)
                            .addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 378, GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE)))
                    .addGroup(panel1Layout.createParallelGroup()
                        .addGroup(panel1Layout.createSequentialGroup()
                            .addGap(0, 0, Short.MAX_VALUE)
                            .addComponent(scrollPane0, GroupLayout.PREFERRED_SIZE, 378, GroupLayout.PREFERRED_SIZE)
                            .addGap(0, 0, Short.MAX_VALUE)))
                    .addGroup(panel1Layout.createSequentialGroup()
                        .addComponent(scrollPane2, GroupLayout.PREFERRED_SIZE, 378, GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 6, Short.MAX_VALUE))
            );
        }

        GroupLayout contentPaneLayout = new GroupLayout(contentPane);
        contentPane.setLayout(contentPaneLayout);
        contentPaneLayout.setHorizontalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(panel1, GroupLayout.PREFERRED_SIZE, 708, GroupLayout.PREFERRED_SIZE))
        );
        contentPaneLayout.setVerticalGroup(
            contentPaneLayout.createParallelGroup()
                .addGroup(contentPaneLayout.createSequentialGroup()
                    .addComponent(panel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE))
        );
        pack();
        setLocationRelativeTo(getOwner());
        // JFormDesigner - End of component initialization  //GEN-END:initComponents
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner Evaluation license - unknown
    private JMenuBar menuBar1;
    private JMenu Designer;
    private JMenuItem menuItem1;
    private JMenuItem menuItem0;
    private JMenu menuUser;
    private JMenuItem menuItem11;
    private JMenuItem menuItem12;
    private JMenu menuBook;
    private JMenuItem menuItem23;
    private JMenuItem menuItem21;
    private JMenuItem menuItem22;
    private JMenu menuBookType;
    private JMenuItem menuItem31;
    private JMenuItem menuItem32;
    private JMenuItem menuItem33;
    private JLayeredPane layeredPane1;
    private JButton UpdateTable;
    private JPanel panel1;
    private JScrollPane scrollPane2;
    private JTable tableBookType;
    private JScrollPane scrollPane0;
    private JTable tableUser;
    private JScrollPane scrollPane1;
    private JTable tableBook;
    private JScrollPane scrollPane3;
    private JLabel label1;
    // JFormDesigner - End of variables declaration  //GEN-END:variables
}
